package logic

import (
	"context"
	"house/houseclient"
	"house/models"

	"house/house"
	"house/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HousesListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHousesListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HousesListLogic {
	return &HousesListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 房源列表
func (l *HousesListLogic) HousesList(in *house.HousesListReq) (*house.HousesListResp, error) {
	// todo: 房源列表
	var h models.House
	list := h.FindHouses()
	var lists []*house.HousesList
	for _, v := range list {
		lists = append(lists, &houseclient.HousesList{
			City:    v.City,
			Address: v.Address,
			Floor:   v.Floor,
			Size:    float32(v.Size),
			Price:   int64(v.Price),
			Info:    v.Info,
			Status:  int64(v.Status),
			UserId:  int64(v.UserId),
		})
	}

	return &house.HousesListResp{
		List: lists,
	}, nil
}
